package com.example.Android_test.util;

import com.example.Android_test.R;
import com.example.Android_test.activity.Main;

/**
 * Created with IntelliJ IDEA.
 * User: anpi0413
 * Date: 28.05.13
 * Time: 18:41
 * To change this template use File | Settings | File Templates.
 */
public class TrainingUtils {
    public static final String ID_TRAINING_ETR = "ETR";
    public static final String ID_TRAINING_TW = "TW";
    public static final String ID_TRAINING_PUWIC = "PUWIC";
    public static final String ID_TRAINING_GD = "GD";
    public static final String ID_TRAINING_SPRINT = "SPRINT";

    public static final String NAME_TRAINING_ETR = Main.getAppContext().getResources().getString(R.string.training_name_etr);
    public static final String NAME_TRAINING_TW = Main.getAppContext().getResources().getString(R.string.training_name_tw);
    public static final String NAME_TRAINING_PUWIC = Main.getAppContext().getResources().getString(R.string.training_name_puwic);
    public static final String NAME_TRAINING_GD = Main.getAppContext().getResources().getString(R.string.training_name_gd);
    public static final String NAME_TRAINING_SPRINT = Main.getAppContext().getResources().getString(R.string.training_name_sprint);

    public static final String DESCRIPTION_TRAINING_ETR = Main.getAppContext().getResources().getString(R.string.training_description_etr);
    public static final String DESCRIPTION_TRAINING_TW = Main.getAppContext().getResources().getString(R.string.training_description_tw);
    public static final String DESCRIPTION_TRAINING_PUWIC = Main.getAppContext().getResources().getString(R.string.training_description_puwic);
    public static final String DESCRIPTION_TRAINING_GD = Main.getAppContext().getResources().getString(R.string.training_description_gd);
    public static final String DESCRIPTION_TRAINING_SPRINT = Main.getAppContext().getResources().getString(R.string.training_description_sprint);

    public static String getNameByID(String id) {
        if (id.equals(ID_TRAINING_ETR)) {
            return NAME_TRAINING_ETR;
        }
        if (id.equals(ID_TRAINING_GD)) {
            return NAME_TRAINING_GD;
        }
        if (id.equals(ID_TRAINING_PUWIC)) {
            return NAME_TRAINING_PUWIC;
        }
        if (id.equals(ID_TRAINING_SPRINT)) {
            return NAME_TRAINING_SPRINT;
        }
        if (id.equals(ID_TRAINING_TW)) {
            return NAME_TRAINING_TW;
        }

        return null;
    }

    public static String getDescriptionByID(String id) {
        if (id.equals(ID_TRAINING_ETR)) {
            return DESCRIPTION_TRAINING_ETR;
        }
        if (id.equals(ID_TRAINING_GD)) {
            return DESCRIPTION_TRAINING_GD;
        }
        if (id.equals(ID_TRAINING_PUWIC)) {
            return DESCRIPTION_TRAINING_PUWIC;
        }
        if (id.equals(ID_TRAINING_SPRINT)) {
            return DESCRIPTION_TRAINING_SPRINT;
        }
        if (id.equals(ID_TRAINING_TW)) {
            return DESCRIPTION_TRAINING_TW;
        }

        return null;
    }

    public static String getMessageForResult(int goodCount, int badCount) {
        double result = (double) goodCount/(goodCount+badCount);

        if (result >= 0.8) {
            return "excellent";
        }
        if (result >= 0.5) {
            return "good";
        }

        return "bad";
    }
}
